<template>
	<view class="myOrderBox">
            <view class="">
                <view class="">
                    
                </view>
            </view>
		
		
            <view class="artItem bgWhite   mlr15 mb15 justify-between align-center" v-for="(i,n) in orderList" :key="n">
                    
                <view class="flex-col  left align-center justify-center mr20 ">
                    <view class="name"><text style="font-size: 32rpx;"> ￥</text> {{i.min_amount}}</view>
                    <text class="desc">满{{i.max_amount}}元可用</text>
                </view>
                <view class="flex1">
                    有效期：{{i.start_date}} 至{{i.end_date}}
                </view>
                <view class="service " @click="getCoupon(i)">
                        领取
                </view>
            </view>

        <view class="" v-if="orderList.length==0">
            <uv-empty mode="data" icon="https://cdn.uviewui.com/uview/empty/data.png"></uv-empty>
        </view>
	
	</view>
</template>

<script>
	export default {
		data() {
			return {
				titleFlag: 0,
                orderList:[],
                allCarData:[],
                orderItem:{},
                imgList:[],
                user_id:uni.getStorageSync('userId')

			};
		},
		onLoad() {
            
		},
		onShow() {
			if (!uni.getStorageSync('logintoken')) {
				uni.reLaunch({
					url: '/pages/login/login'
				})
				return
			}
			this.getOrder()
		},
		methods: {
            formateTime(data){
              return this.$utils.formatDateTime(data)  
            },
			//立即支付
			payBtn(){
				uni.navigateTo({
					url:'/pages/mine/payment'
				})
			},
			//更多照片
			
			//验证车弹窗关闭
			carImgClose(){
				this.$refs.checkCar.close();
			},
			async getOrder() {
				let data = await this.$api.couponList()
				console.log(data)
                this.orderList = data.data
			},

			goBack() {
				uni.navigateBack({
					delta: 1
				})
			},
			//待支付按钮
			unpaidBtn(type) {
				this.titleFlag = type
				this.getOrder()
			},

			//合同按钮
			contractBtn() {
				this.$refs.dzContract.open();
			},
			//合同弹窗关闭
			contractClose() {
				this.$refs.dzContract.close();
			},
			//全部车辆弹窗
			allCarBtn(data) {
                this.orderItem = data
                this.allCarData =JSON.parse(data.car_arr)
				this.$refs.carModal.open();
			},
			//车辆弹窗关闭
			carClose() {
				this.$refs.carModal.close();
			},
            async  showAllImg(item){
                const {data}  =   await  this.$api.cartImage({order_id:item.id})
                console.log(data)
                this.imgList = data.list
                this.$refs.checkCar.open();
            },
            async getImglist(id){
                const {data}  =   await  this.$api.cartImage({order_id:id})
                
                return data.list
            },
            toMain(item){
                    uni.navigateTo({
                        url:'/pages/orderDetail/index?id='+item.id
                    })
            },
            submitpz(id){
                    uni.navigateTo({
                        url:'/pages/pay/index?id='+id
                    })
            },
            async getCoupon(item){
                    
               this.$api.getCoupon({coupon_id:item.id,user_id:this.user_id}).then(res=>{
                   console.log(res)
                       
                   if(res.code==200){
                       uni.showToast({
                           title:'领取成功'
                       })
                   }
                })
                
            }
		}
	}
</script>

<style lang="scss" scoped>
	.myOrderBox {
		min-height: 100vh;
		position: relative;
		background-color: RGBA(245, 245, 245, 1);
        padding-top: 20rpx;
		.orderTitle {
			width: 750rpx;
			height: 98rpx;
			// background-color: #FFFFFF;
			display: flex;
			font-size: 26rpx;
			color: #666666;
            border-bottom: 2rpx solid  rgba(151,151,151,0.062);
			.titleItem {
				height: 98rpx;
				line-height: 98rpx;
				text-align: center;
				flex-basis: 0rpx;
				flex-grow: 1;
				font-weight: 600;
			}

			.active {
				height: 98rpx;
				line-height: 98rpx;
				text-align: center;
				flex-basis: 0rpx;
				flex-grow: 1;
				color: #000000;
				position: relative;
				font-weight: 600;
			}

			.active::after {
				position: absolute;
				content: "";
				width: 74rpx;
				height: 4rpx;
				bottom: 0rpx;
				left: 50%;
				transform: translateX(-50%);
				background: #2CC6A1;
			}
		}

	}	
    .submitPz{
        width: 165rpx;
        height: 54rpx;
        background: #434343;
        border-radius: 6rpx;
        font-size: 24rpx;
        color: #FFFFFF;
        text-align: center;
        line-height: 54rpx;
    }
    .artItem {
        box-shadow: 0rpx 0rpx 12rpx 0rpx rgba(0,0,0,0.0612);
        font-size: 24rpx;
        border-radius: 16rpx 16rpx 16rpx 16rpx;
        margin-bottom: 36rpx;
            font-size: 24rpx;
            color: #666666;
        .left{
            width: 224rpx;
            height: 180rpx;
            background: #FFF2F2;
            border-radius: 12rpx 12rpx 12rpx 12rpx;
        }
        .desc{
           font-weight: 600;
           font-size: 32rpx;
           color: #E6220A; 
        }
        .name{
       font-weight: 600;
       font-size: 64rpx;
       color: #E6220A;
        }
    }
    .service{
        width: 140rpx;
        height: 66rpx;
        background: #E6220A;
        color: #fff;
        text-align: center;
        font-size: 32rpx;
        line-height: 66rpx;
        border-radius: 60rpx 60rpx 60rpx 60rpx;
        margin-right: 20rpx;
    }
</style>